<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生考试管理系统 - 仪表盘</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
    <style>
        .card {
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .card-header {
            background-color: #f8f9fa;
            border-bottom: none;
            font-weight: bold;
        }
        .stats-card {
            text-align: center;
            padding: 20px;
        }
        .stats-icon {
            font-size: 3rem;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container">
        <a class="navbar-brand" href="../../dashboard.html">
            <i class="fa fa-graduation-cap mr-2"></i>学生考试管理系统
        </a>

        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a class="nav-link" href="../../dashboard.html">仪表盘</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="../../exams.html">在线考试</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="examResult.jsp">成绩查询</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="../../profile.html">个人信息</a>
                </li>
            </ul>

            <ul class="navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                        <i class="fa fa-user-circle mr-1"></i>张三 (20230001)
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item" href="../../profile.html">个人信息</a></li>
                        <li><a class="dropdown-item" href="../../changePassword.html">修改密码</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="../../login.html">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

<!-- 主内容 -->
<div class="container mt-4">
    <div class="row">
        <!-- 统计卡片 -->
        <div class="col-md-4">
            <div class="card stats-card bg-primary text-white">
                <div class="stats-icon">
                    <i class="fa fa-calendar-check-o"></i>
                </div>
                <h3>即将进行的考试</h3>
                <p class="fs-1">2</p>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card stats-card bg-success text-white">
                <div class="stats-icon">
                    <i class="fa fa-check-circle"></i>
                </div>
                <h3>已完成的考试</h3>
                <p class="fs-1">1</p>
            </div>
        </div>

        <div class="col-md-4">
            <div class="card stats-card bg-info text-white">
                <div class="stats-icon">
                    <i class="fa fa-line-chart"></i>
                </div>
                <h3>平均成绩</h3>
                <p class="fs-1">85.5</p>
            </div>
        </div>
    </div>

    <div class="row mt-4">
        <!-- 即将进行的考试 -->
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-calendar mr-2"></i>即将进行的考试
                </div>
                <div class="card-body">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>考试名称</th>
                            <th>考试时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>Java程序设计</td>
                            <td>2025-06-20 09:00</td>
                            <td>
                                <a href="takeExam.jsp" class="btn btn-primary btn-sm">参加考试</a>
                            </td>
                        </tr>
                        <tr>
                            <td>数据结构</td>
                            <td>2025-06-25 14:00</td>
                            <td>
                                <button class="btn btn-secondary btn-sm" disabled>未激活</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <!-- 最近成绩 -->
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-graduation-cap mr-2"></i>最近成绩
                </div>
                <div class="card-body">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>课程名称</th>
                            <th>考试时间</th>
                            <th>成绩</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>Java程序设计</td>
                            <td>2025-06-20</td>
                            <td>
                                <span class="badge bg-success">85.5</span>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="text-right">
                        <a href="scores.html" class="btn btn-outline-primary btn-sm">查看全部</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 成绩统计图表 -->
    <div class="row mt-4">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-bar-chart mr-2"></i>成绩统计
                </div>
                <div class="card-body">
                    <canvas id="scoreChart" height="100"></canvas>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 页脚 -->
<footer class="bg-light text-center text-muted mt-5 py-3">
    <div class="container">
        <p>© 2025 学生考试管理系统 | 由管理员分配账户</p>
    </div>
</footer>

<script>
    // 初始化成绩统计图表
    document.addEventListener('DOMContentLoaded', function() {
        const ctx = document.getElementById('scoreChart').getContext('2d');

        // 创建图表
        new Chart(ctx, {
            type: 'bar',
            data: {
                labels: ['Java程序设计'],
                datasets: [{
                    label: '成绩',
                    data: [85.5],
                    backgroundColor: 'rgba(13, 110, 253, 0.7)',
                    borderColor: 'rgb(13, 110, 253)',
                    borderWidth: 1
                }]
            },
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 100
                    }
                }
            }
        });
    });
</script>
</body>
</html>